//
//  WLHttpManager.h
//  WanLian
//
//  Created by muzhuang on 2018/9/12.
//  Copyright © 2018年 wanlian. All rights reserved.
//

/**
 网络模块
 */
#import <Foundation/Foundation.h>

/**
 此方法设置测试跟正式服务器的 baseurl//192.168.2.203
 */

#if DEBUG

//static NSString* const BASEURL = @"http://47.75.195.106/router/";
static NSString* const BASEURL = @"https://www.zeerong.com/router/web";

#else

static NSString* const BASEURL = @"https://www.zeerong.com/router/web";

#endif

/**
 请求类型
 
 - RequestTypeGet:      get 类型
 - RequestTypePost:     post 类型
 - RequestTypeUpLoad:   上传类型
 - RequestTypeDownload: 下载类型
 */
typedef NS_ENUM(NSInteger,RequsetMethod){
    RequestTypeGet,
    RequestTypePost,
    RequestTypeUpLoad,
    RequestTypeDownload,
};

@interface WLHttpManager : NSObject

+ (AFHTTPSessionManager*)httpManager;

+ (void)WLRequestMethod:(RequsetMethod)method
                 urlStr:(NSString *)urlStr
          withParamsDic:(NSDictionary *)parameters
                success:(void (^)(NSDictionary *successDict))success
                failure:(void (^)(NSString *errorMsg, NSInteger errorTag))failure
                  error:(void (^)(NSError *error))err
                 inView:(UIView *)showView;

+ (NSURLSessionDataTask *)WLUpDownloadPost:(NSString *)URLString
                                parameters:(NSDictionary *)parameters
                 constructingBodyWithBlock:( void (^)(id <AFMultipartFormData> formData))block
                                  progress:(void (^)(NSProgress *uploadProgress))uploadProgress
                                   success:(void (^)(NSDictionary *successDict))success
                                   failure:(void (^)(NSString *errorMsg, NSInteger errorTag))failure
                                     error:(void (^)(NSError *error))err
                                    inView:(UIView *)showView;
/** 自带host的网络请求  */
+ (NSURLSessionDataTask *)WLBackgroundUploadPost:(NSString *)URLString
                                    parameters:(NSDictionary *)parameters
                     constructingBodyWithBlock:( void (^)(id <AFMultipartFormData> formData))block
                                      progress:(void (^)(NSProgress *uploadProgress))uploadProgress
                                       success:(void (^)(NSDictionary *successDict))success
                                       failure:(void (^)(NSString *errorMsg, NSInteger errorTag))failure
                                         error:(void (^)(NSError *error))err
                                        inView:(UIView *)showView;

+ (NSURLSessionDataTask *)WLBackgroundDownloadGet:(NSString *)URLString
                                       parameters:(NSDictionary *)parameters
                                         progress:(void (^)(NSProgress *uploadProgress))downloadProgress
                                          success:(void (^)(NSDictionary *successDict))success
                                          failure:(void (^)(NSString *errorMsg, NSInteger errorTag))failure
                                            error:(void (^)(NSError *error))err
                                           inView:(UIView *)showView;
@end
